package main

import (
	"context"
	"fmt"
	"gitee.com/jinmingzhi/eth-learn/pkg/ethtool"
	"github.com/ethereum/go-ethereum/common"
)

var (
	url  = "http://localhost:8545"
	txId = "0x46e4809ce5f6df6ac81821b35139414a40917a60dadaf5d10dbed9efb4dcc9a0"
)

func main() {
	client, err := ethtool.Dial(url)
	assert(err)
	ctx := context.Background()
	res, err := client.EthGetTransactionReceipt(ctx, common.HexToHash(txId))
	assert(err)
	fmt.Println("EthGetTransactionReceipt:", res)

	count, err := client.EthGetTransactionCount(ctx, common.HexToAddress("0xd8C7788Fc017D161813aCcEB90225e900080d42B"), "latest")
	assert(err)
	fmt.Println("count:", count)
}

func assert(err error) {
	if err != nil {
		panic(err)
	}
}
